#ifndef YCEXTENSIONWINDOW_H
#define YCEXTENSIONWINDOW_H
#include "extensiontype.h"
#include <QPointer>
#include <QWidget>

namespace yc {
class Extension;
class ExtensionManager;

class YCEXTENSIONSHARED_EXPORT ExtensionWindow : public QWidget
{
    Q_OBJECT

public:
    explicit ExtensionWindow(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
    ExtensionWindow(Extension* extension, QWidget* parent, Qt::WindowFlags f = Qt::WindowFlags());
    ~ExtensionWindow();

    Extension* extension() const;
    void setExtension(Extension* extension);
    void stopExtension(ResolveCallback resolve);
    void requestStop();
    void stop();

Q_SIGNALS:
    void stopped();
    void stopIgnored();

protected:
    void changeEvent(QEvent* e) override;
    void closeEvent(QCloseEvent* e) override;

private:
    void requestStopExtension(ResolveCallback resolve, RejectCallback reject);
    void stopExtension();
    void setupUi();

    QPointer<Extension> extension_;
    bool force_stop_requested_;
    bool stopping_;
};
} // namespace yc

#endif // YCEXTENSIONWINDOW_H
